#include <stdio.h>
#include "getch.h"
#define N 10

void hidepwd(char *p, int n);

int main(int argc, char *argv[])
{
    char pwd[N];
    printf("PASSWORD:");
    fflush(stdin);
    hidepwd(pwd, N);
    printf("---->: %s\n", pwd);
	    
    return 0;
}

void hidepwd(char *p, int n)
{
    int ch, i = 0;
    while ((ch = getch()) != '\n')
    {
        if(ch == 127) {
            if(i > 0) i--;
        } else {
            p[i++] = ch;
            if(i > n) i = n;
        }
    }
    p[i] = '\0';
    printf("\n");
}
